<%@ Page Language="VB" MasterPageFile="~/Default.master" Title="Untitled Page" ValidateRequest="false" %>

<%@ Import Namespace="System.Data" %>

<%@ Register TagPrefix="Club" TagName="LoginBanner" Src="~/UserControls/LoginBanner.ascx" %>
<%@ Register TagPrefix="Club" TagName="ImageThumbnail" Src="~/UserControls/ImageThumbnail.ascx" %>
<%@ Register TagPrefix="Club" TagName="Photopicker" Src="~/UserControls/photos_formpicker.ascx" %>
<%@ Register TagPrefix="Club" TagName="Dateandtimepicker" Src="~/UserControls/Dateandtimepicker.ascx" %>
<%@ Register TagPrefix="Club" TagName="PhotoAlbumPicker" Src="~/UserControls/photoalbum_picker.ascx" %>

<script runat="server">

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs)
        If IsPostBack = False Then
            dtpicker.selectedDateTime = Now()
            albumpick.AlbumID = 0
            Photopicker1.ImageId = 0
        End If
        Session("FCKeditor:UserFilesPath") = Request.ApplicationPath.ToString & "Files/"
    End Sub

    Protected Sub GreenRolloverButton3_Click(ByVal sender As Object, ByVal e As System.EventArgs)
        Dim Title As String = titleTextBox.Text.ToString()
        Dim URL As String = ""
        If CheckBox1.Checked = True Then
            URL = staticURLTextBox.Text
        End If
        
        Dim description As String = "<p></p>"
        If Not FCKeditor1.Value = "" Or IsDBNull(FCKeditor1.Value) = False Then
            description = FCKeditor1.Value
        End If
        
        Dim itemdate As Date = DateTime.Now()
        If IsDBNull(dtpicker.selectedDateTime) = False Then
            itemdate = dtpicker.selectedDateTime()
        End If
        
        Dim photoid As Integer = 0
        If IsDBNull(Photopicker1.ImageId) = False Then
            photoid = Photopicker1.ImageId
        End If
        
        Dim albumid As Integer = 0
        If IsDBNull(albumpick.AlbumID) = False Then
            albumid = Integer.Parse(albumpick.AlbumID.ToString())
        End If
        
        ClubStarterKit.Data.Announcements.Insert(itemdate, Title, description, URL, photoid, albumid)
        Response.Redirect("~/news/list.aspx")
    End Sub
</script>

<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
<div id="body">
        <Club:LoginBanner ID="LoginBanner1" runat="server" />
<div class="fullwidth">
    <h3>
        New News Article</h3>
    <div class="dashedline">
    </div>
    <div>
        <div class="actionbuttons">
            &nbsp;</div>
    </div>
    <div class="dashedline">
    </div>
    <table>
        <tr>
            <td class="formlabel">
                Article Title:
            </td>
            <td align="left">
                <asp:TextBox ID="titleTextBox" runat="server" Width="500px"></asp:TextBox><br />
                <asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server" ControlToValidate="titleTextBox"
                    ErrorMessage="Please enter a title." ToolTip="Please enter a title." ValidationGroup="add">*</asp:RequiredFieldValidator>
            </td>
        </tr>
        <tr>
            <td class="formlabel">
                Link:
            </td>
            <td align="left">
                <asp:CheckBox ID="CheckBox1" runat="server" Text="Use a link instead of inline content for this article." AutoPostBack="true" /><br />
                URL:
                <asp:TextBox runat="server" ID="staticURLTextBox"
                    Width="450px" />
            </td>
        </tr>
        <tr>
            <td class="formlabel">
                Description:
            </td>
            <td align="left">
                    <FCKeditorV2:FCKeditor ID="FCKeditor1" runat="server" ToolbarSet = "Default" SkinPath = "skins/office2003/" Value='<%# Bind("description") %>' BasePath="~/FCKeditor/" UseBROnCarriageReturn="true"></FCKeditorV2:FCKeditor>
                <br />
                <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ControlToValidate="FCKeditor1"
                    EnableClientScript="False" ErrorMessage="Please enter a description." ToolTip="Please enter a description."
                    ValidationGroup="add">*</asp:RequiredFieldValidator>
            </td>
        </tr>
        <tr>
            <td class="formlabel">
                Article Visible Date</td>
            <td align="left">
                The news article will not be visible to users until after this date.
                <Club:Dateandtimepicker ID="dtpicker" runat="server" />
            </td>
        </tr>
        <tr>
            <td class="formlabel">
                Photo:</td>
            <td align="left">
                <Club:Photopicker ID="Photopicker1" runat="server" SmallImage="true" />
            </td>
        </tr>
        <tr>
            <td class="formlabel">
                Photo Album</td>
            <td align="left">
                Optionally, the news article can be assoiated with a photo album.
                <br />
                <Club:PhotoAlbumPicker ID="albumpick" runat="server" />
            </td>
        </tr>
    </table>
    <div class="dashedline">
    </div>
    <div class="actionbuttons">
        <Club:RolloverButton ID="GreenRolloverButton3" Text="Save Article"
            runat="server" CausesValidation="true" ValidationGroup="add" OnClick="GreenRolloverButton3_Click" />
        <Club:RolloverLink ID="GreenRolloverLink2" CausesValidation="false" Text="Cancel" runat="server" NavigateURL="list.aspx" />
    </div>
</div>
<div>
</div>
</div>
</asp:Content>

